<script type="text/javascript">
    function ajaxQuickUpdate(id){
        var status = 0;                
        if($("#status_" + id).is(":checked")){ status = 1; }        
                
        var strUrl = "<?php echo Url::createUrl("appSmsKuteNew/ajaxQuickUpdate");?>";
        $.ajax({
            type: "POST",
            url: strUrl,
            data: {                
                status:status
                , id:id
            },
            success: function(msg){
                if(msg == 1){
                    alert('Sửa thành công');
                    location.reload();
                }else{
                    alert(msg);
                }
            }          
        });
    }
    function ajaxDelete(id){
        var strUrl = "<?php echo Url::createUrl("appSmsKuteNew/ajaxDelete") ?>";
        if(confirm("Bạn có muốn tiếp tục không?")){
            $.ajax({
                type: "POST",
                url: strUrl,
                data: {
                    id:id
                },
                success: function(msg){
                    if(msg == 1){
                        alert('Xóa thành công');
                        location.reload();
                    }else{
                        alert(msg);
                    }
                }          
            });
        }
    }
</script>
<div class="main clearfix">
    <div class="Tabs clearfix">
        <ul class="clearfix">
            <li><a href="<?php echo Url::createUrl("appSmsKuteNew/index");?>" class="active"><span>App Sms Kute</span></a></li>
            <li><a href="<?php echo Url::createUrl("smsKuteNew/index");?>"><span>Sms Kute</span></a></li>                        
        </ul>                
    </div>

    <div class="box">
        <div class="fillter clearfix">
            <div class="fl">
                Tìm thấy <strong class="clred"><?php echo count($app);?></strong> kết quả - 
                <a href="<?php echo Url::createUrl("appSmsKuteNew/add");?>"><input type="button" value=" Thêm mới " class="btn-bigblue"></a>
            </div>            
        </div>
        
        <div class="table clearfix">
            <table width="100%" cellspacing="0" cellpadding="0" border="0">
                <tbody>
                    <tr class="bg-grey">
                        <td width="20%"><strong>Icon</strong></td>
                        <td width="40%"><strong>Tên App sms kute</strong></td>
                        <td width="10%"><strong>Tình trạng</strong></td>
                        <td width="10%"><strong>Số lượng SMS</strong></td>
                        <td width="20%"><strong>Quản trị</strong></td>
                    </tr>
                    <?php foreach($app as $row){ ?>
                    <tr>
                        <td class="middle">
                            <img src="<?php echo Common::getImage($row["picture"], "icon_app_sms_kute", $row["create_date"]);?>" width="32" height="32" class="img-40" />
                        </td>
                        <td class="middle"><strong><?php echo $row["title"];?></strong></td>
                        <td>
                            <input type="checkbox" value="1" id="status_<?php echo $row["id"]?>" <?php if($row["status"]==1) echo "checked";?> > Hiển thị
                        </td>
                        <td class="middle"><?php echo $row["total_sms"];?></td>
                        <td class="middle">
                            <a href="javascript:" onclick="ajaxQuickUpdate(<?php echo $row["id"];?>)"> Lưu </a> | 
                            <a href="<?php echo Url::createUrl("appSmsKuteNew/edit", array("id"=>$row["id"]));?>"> Sửa </a> | 
                            <a href="javascript:" onclick="ajaxDelete(<?php echo $row["id"];?>)"> Xóa </a> 
                        </td>
                    </tr>
                    <?php } ?>                    
                </tbody>
            </table>
        </div>        
    </div>
</div>
